package com.ruoyi.lock.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.lock.domain.AppVersion;
import com.ruoyi.lock.mapper.AppVersionMapper;
import com.ruoyi.lock.service.IAppVersionService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * versionService业务层处理
 *
 * @author ruoyi
 * @date 2021-05-07
 */
@Service
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class AppVersionServiceImpl implements IAppVersionService {
    private final AppVersionMapper appVersionMapper;

    /**
     * 查询version
     *
     * @param id versionID
     * @return version
     */
    @Override
    public AppVersion selectAppVersionById(Long id) {
        return appVersionMapper.selectAppVersionById(id);
    }

    /**
     * 查询version列表
     *
     * @param appVersion version
     * @return version
     */
    @Override
    public List<AppVersion> selectAppVersionList(AppVersion appVersion) {
        return appVersionMapper.selectAppVersionList(appVersion);
    }

    /**
     * 新增version
     *
     * @param appVersion version
     * @return 结果
     */
    @Override
    public int insertAppVersion(AppVersion appVersion) {
        appVersion.setCreateTime(DateUtils.getNowDate());
        appVersion.setCreateBy(SecurityUtils.getUsername());
        return appVersionMapper.insertAppVersion(appVersion);
    }

    /**
     * 修改version
     *
     * @param appVersion version
     * @return 结果
     */
    @Override
    public int updateAppVersion(AppVersion appVersion) {
        appVersion.setUpdateTime(DateUtils.getNowDate());
        return appVersionMapper.updateAppVersion(appVersion);
    }

    /**
     * 批量删除version
     *
     * @param ids 需要删除的versionID
     * @return 结果
     */
    @Override
    public int deleteAppVersionByIds(Long[] ids) {
        return appVersionMapper.deleteAppVersionByIds(ids);
    }

    /**
     * 删除version信息
     *
     * @param id versionID
     * @return 结果
     */
    @Override
    public int deleteAppVersionById(Long id) {
        return appVersionMapper.deleteAppVersionById(id);
    }

    @Override
    public AppVersion checkVersion(String version) {
        return appVersionMapper.checkVersion(version);
    }
}
